<?php
/**
 * Created by PhpStorm.
 * User: 曹乐清
 * Date: 2017/3/21
 * Time: 13:46
 */

namespace Home\Controller;


use Think\Auth;
use Think\Controller;

class CommonController extends Controller
{
    public function _initialize()
    {

        if(!isset($_SESSION['user']['id'])){
            $this->redirect('/Home/User/login');
        }
      import('ORG.Util.Auth');//加载类库
        $auth=new Auth();
        if(!$auth->check(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME,$_SESSION['user']['id'])){
                if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
                      $this->ajaxReturn(array('success'=>false,'message'=>'您没有权限'));
                }else{
                    $this->error('你没有权限');
                }

         }
    }
}